from pathlib import Path
import shutil


def delete_directory_contents(directory):
    p = Path(directory)
    for child in p.iterdir():
        try:
            if child.is_dir():
                shutil.rmtree(child)
            else:
                child.unlink()
        except Exception as e:
            print(f'Failed to delete {child}. Reason: {e}')



if __name__ == '__main__':
    directory_path = r'D:\dev\polaris_rag\db'
    delete_directory_contents(directory_path)